/**
 *    Copyright 2009 Seth Albnaese
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.aquiferserver.client.flex
{
	import flash.utils.ByteArray;
	import flexunit.framework.TestCase;
	import org.aquiferserver.common.HandshakeConfirmationMessage;
	import org.aquiferserver.common.Player;
	import flash.net.registerClassAlias;
	import mx.utils.Base64Decoder;
	import mx.utils.Base64Encoder;
	
	import org.aquiferserver.client.flex.SerializationCodec;
	
	/**
	 * ...
	 * @author bob
	 */
	public class TestSerializationCodec extends TestCase
	{
		
		public function testSerializationCodec() : void
		{
			registerClassAlias( "org.aquiferserver.common.HandshakeConfirmationMessage", org.aquiferserver.common.HandshakeConfirmationMessage );
			registerClassAlias( "org.aquiferserver.common.Player", org.aquiferserver.common.Player );
			
			var p:Player = new Player();
			p.id = 1234;
			p.addProperty( "name", "seth" );
			
			var msg:HandshakeConfirmationMessage = new HandshakeConfirmationMessage();
			msg.player = p;
			msg.sender = 324;
			
			var ba:ByteArray = new ByteArray();
			ba.writeObject( msg );
			ba.position = 0;
			var dmsg:HandshakeConfirmationMessage = ba.readObject();			
			
			/*
			var s:String = SerializationCodec.serialize( msg );
			
			var dmsg:HandshakeConfirmationMessage = SerializationCodec.deserialize( s );
			*/
			assertTrue( dmsg.player.id == msg.player.id );
			
		}
		
	}
	
}